import {defineStore} from 'pinia'
import {request_post_login_user, LOGIN_USER} from '../service/login'
import {reactive} from 'vue'

export default defineStore('useLoginStore', () => {
    const userInfoData = reactive({
        id: 0,
        nickname: ''
    })
    const loginUser = async (userInfo: LOGIN_USER) => {
        const res = await request_post_login_user(userInfo)
        userInfoData.id = res?.data?.id
        userInfoData.nickname = res?.data?.nickname
        return res
    }
    return {
        loginUser,
        userInfoData
    }
})